﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using graphical_function_explorer.CalculationLogic;

namespace graphical_function_explorer
{
    public static class ItemProvider
    {
        public static char horizAxisVar;
        public static char vertAxisVar;

        public static LinkedList<string> equationList;
        public static LinkedList<string> fullEquationList;

        public static LinkedList<double[]> valuesCollection;

        public static void InitializeLists()
        {
            equationList = new LinkedList<string>();
            fullEquationList = new LinkedList<string>();

            valuesCollection = new LinkedList<double[]>();
        }

        public static void AddFunction(char mainVar, string equation)
        {
            equationList.AddLast(equation);
            fullEquationList.AddLast(mainVar + " = " + equation);

            valuesCollection.AddLast(CalculationController.CalculateValues(equation));
            //-------------------------------------------------------------------------------------------------
            for (int q = 0; q < valuesCollection.Last.Value.Length; q++)
                Console.WriteLine(valuesCollection.Last.Value[q]);
            //-------------------------------------------------------------------------------------------------
        }

        public static char GetFunctionVariable(char mainVar)
        {
            if (mainVar == horizAxisVar)
                return vertAxisVar;
            else
                return horizAxisVar;
        }

        public static char GetLastMainVariable()
        {
            char mainVar = fullEquationList.Last.Value.ToString().Substring(0, 1)[0];

            return mainVar;
        }
    }
}
